package com.example.dropoff;



import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;


public class popupactivity1 extends Activity
 {
	private EditText[] mEditTexts;
	boolean mInitSpinner;
	private DbOpenHelper mDbOpenHelper;
	private static Context mcontext;
    

		
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
         WindowManager.LayoutParams layoutParams= new WindowManager.LayoutParams();
         layoutParams.flags= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
         layoutParams.dimAmount= 0.7f;
         getWindow().setAttributes(layoutParams);
         setContentView(R.layout.activity_popup);
         mDbOpenHelper = new DbOpenHelper(this);
         mDbOpenHelper.open();
         setLayout();
         mcontext = this;

        
     
     
         
         findViewById(R.id.popup_save).setOnClickListener(mClickListener);
         findViewById(R.id.popup_cancel).setOnClickListener(mClickListener);
         
        
        
     } 	   
    
    
     
     Button.OnClickListener mClickListener = new View.OnClickListener() {
 		public void onClick(View v) {
 			int id = v.getId();
			switch (id) {
			case R.id.popup_save:
				mDbOpenHelper.insertColumn
 				(
 				mEditTexts[Constants.NAME].getText().toString().trim(),
 				mEditTexts[Constants.DATE_YY].getText().toString().trim(),
 				mEditTexts[Constants.DATE_MM].getText().toString().trim(),
 				mEditTexts[Constants.DATE_DD].getText().toString().trim(),
 				mEditTexts[Constants.AMOUNT].getText().toString().trim(),
 				mEditTexts[Constants.UNIT].getText().toString().trim(),
 				mEditTexts[Constants.MEMO].getText().toString().trim()
 				);
				finish();
				break;
			case R.id.popup_cancel:
				finish();
				break;
			}
 		}
 	};
     protected void onDestroy() {
    	   	mDbOpenHelper.close();
    	   	super.onDestroy();
    	   }
     
     
     
         private void setLayout(){
     	 mEditTexts = new EditText[]{
     			(EditText)findViewById(R.id.item_name),
     			(EditText)findViewById(R.id.item_date_yy),
     			(EditText)findViewById(R.id.item_date_mm),
     			(EditText)findViewById(R.id.item_date_dd),
     			(EditText)findViewById(R.id.item_amount),
     			(EditText)findViewById(R.id.item_unit),
     			(EditText)findViewById(R.id.item_memo)
     	};
     	
     
     }
    }
